package com.itheima.mapper;

import com.itheima.pojo.OrderSettingReturn;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface OrdersettingMapper {

    /**
     * 根据日期修改可预约人数
     * @param number
     * @param localDate
     * @return
     */
    @Update("update t_ordersetting set number = #{number} where orderDate = #{localDate}")
    void editNumberByOrderDate(int number, LocalDate localDate);

    @Select("select orderdate, number, reservations from t_ordersetting where orderDate between #{begintime} and #{endtime}")
    List<OrderSettingReturn> getOrderSettingByMonth(LocalDate begintime, LocalDate endtime);

    @Insert("insert into t_ordersetting (orderDate,number,reservations) values (#{date},#{number},#{reservations})")
    void addOrderSetting(LocalDate date, int number, int reservations);

    @Select("select count(*) from t_ordersetting where orderDate in (#{begin} , #{end})")
    Integer getOrderCount(LocalDate begin, LocalDate end);

    @Select("select sum(reservations) from t_ordersetting")
    Integer getTotalCount();
}
